/*-----------------------------------------------------------------------------*/
/* ExternAdmin.java                                                              */
/* external administrator for ecom application                                 */
/* Fabienne Boyer - Didier Donsez may 2006                                     */
/*-----------------------------------------------------------------------------*/
package ecom.client;

import ecom.beans.address.*;
import ecom.beans.account.*;
import ecom.beans.cart.*;
import ecom.beans.customer.*;
import ecom.beans.dish.*;
import ecom.beans.customer.*;
import ecom.beans.store.*;
import ecom.client.*;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.List;
import javax.ejb.EJB;

import javax.transaction.*;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

// RMI administrator for the ecom application.
public class ExternAdmin {

   private Context initialContext;
    private UserTransaction utx;
	
    private DishEntityFacadeRemote dishEntityFacade;
    private AccountEntityFacadeRemote accountEntityFacade;
    private CustomerEntityFacadeRemote customerEntityFacade;
    private StoreEntityFacadeRemote storeEntityFacade;
	private AddressEntityFacadeRemote addressEntityFacade;
	private CartSessionRemote cartSessionBean;

	ExternAdmin() {

        initialContext = null;
        utx = null;
        dishEntityFacade = null;
        accountEntityFacade = null;
        customerEntityFacade = null;
        storeEntityFacade = null;
		addressEntityFacade = null;
		cartSessionBean = null;

        System.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.objectweb.carol.jndi.spi.MultiOrbInitialContextFactory");

        try {
            initialContext = new InitialContext();
        } catch (Exception e) {
            System.err.println("Cannot get initial context for JNDI: " + e);
            System.exit(2);
        }

        try {
            utx = (UserTransaction) initialContext.lookup("javax.transaction.UserTransaction");
        } catch (NamingException e) {
            System.err.println("Cannot lookup UserTransaction: " + e);
            System.exit(2);
        }

		
        try {
            dishEntityFacade = (DishEntityFacadeRemote) initialContext.lookup("ecom.beans.dish.DishEntityFacade" + "_" + DishEntityFacadeRemote.class.getName() + "@Remote");

            System.out.println("Creation of dishEntityFacade...OK");



        } catch (NamingException e) {
            System.err.println("Cannot get dishEntityFacade : " + e);
            System.exit(2);
        }


        try {
            storeEntityFacade = (StoreEntityFacadeRemote) initialContext.lookup("ecom.beans.store.StoreEntityFacade" + "_" + StoreEntityFacadeRemote.class.getName() + "@Remote");

            System.out.println("Creation of storeEntityFacade...OK");



        } catch (NamingException e) {
            System.err.println("Cannot get storeEntityFacade : " + e);
            System.exit(2);
        }

        try {
            customerEntityFacade = (CustomerEntityFacadeRemote) initialContext.lookup("ecom.beans.customer.CustomerEntityFacade" + "_" + CustomerEntityFacadeRemote.class.getName() + "@Remote");

            System.out.println("Creation of customerEntityFacade...OK");



        } catch (NamingException e) {
            System.err.println("Cannot get customerEntityFacade : " + e);
            System.exit(2);
        }


        try {
            accountEntityFacade = (AccountEntityFacadeRemote) initialContext.lookup("ecom.beans.account.AccountEntityFacade" + "_" + AccountEntityFacadeRemote.class.getName() + "@Remote");

            System.out.println("Creation of accountEntityFacade...OK");



        } catch (NamingException e) {
            System.err.println("Cannot get accountEntityFacade : " + e);
            System.exit(2);
        }
		
		
		try {
            addressEntityFacade = (AddressEntityFacadeRemote) initialContext.lookup("ecom.beans.address.AddressEntityFacade" + "_" + AddressEntityFacadeRemote.class.getName() + "@Remote");

            System.out.println("Creation of addressEntityFacade...OK");

        } catch (NamingException e) {
            System.err.println("Cannot get addressEntityFacade : " + e);
            System.exit(2);
        }
		
		try {
            cartSessionBean = (CartSessionRemote) initialContext.lookup("ecom.beans.cart.CartSessionBean" + "_" + CartSessionRemote.class.getName() + "@Remote");

            System.out.println("Creation of cartSessionBean...OK");

        } catch (NamingException e) {
            System.err.println("Cannot get cartSessionBean : " + e);
            System.exit(2);
        }
		
		
    }

	/**************************************************************/
	public void admin() {
        try {

            while (true) {
                System.out.println("------------------------------------------------------");
                System.out.println("Entrez une commande :");
                System.out.println("1 = Gerer les restaurants ");
                System.out.println("2 = Gerer les plats ");
                System.out.println("3 = Gerer les comptes clients ");                
                System.out.println("0 = quitter l'application \n");

                int choice = Tx.readInt();

                if (choice == 1) {
                    boolean inRestoSubMenu = true;
                    while (inRestoSubMenu) {
                        System.out.println("------------------------------------------------------");
                        System.out.println("Entrez une commande :");
                        System.out.println("1 = creer un restaurant ");
                        System.out.println("2 = voir la liste des restaurants ");
                        System.out.println("3 = supprimer un restaurant ");
                        System.out.println("4 = supprimer tous les restaurants ");
                        System.out.println("0 = Revenir au menu principal\n");
                        int choiceResto = Tx.readInt();
                        List<StoreEntity> storeList;
                        switch (choiceResto) {
                            case 1:
                                createResto();
                                break;
                            case 2:
                                storeList = storeEntityFacade.getAllStores();
                                if (storeList == null || storeList.size() == 0) {
                                    System.out.println("Il n'y a aucun restaurant.");
                                } else {
                                    for (StoreEntity store : storeList) {
                                        System.out.println("Nom du restaurant : " + store.getStoreName());
                                        System.out.println("IBAN du compte du restaurant : " + store.getStoreAccount().getAccountIBAN());
                                        System.out.println("Solde du compte du restaurant : " + store.getStoreAccount().getAccountBalance());
                                        System.out.println("--------------------------------------------");
                                    }
                                }
                                break;
                            case 3:
                                removeResto();
                                break;
                            case 4:
                                storeList = storeEntityFacade.getAllStores();
                                if (storeList == null || storeList.size() == 0) {
                                    System.out.println("Il n'y a aucun restaurant a supprimer");
                                } else {
                                    for (StoreEntity store : storeList) {
                                        dishEntityFacade.removeAllDishesByRestoId(store.getId());
                                    }
                                    List<StoreEntity> storeListToDel = storeEntityFacade.removeAllStore();
                                    System.out.println("Les restaurants suivants ont ete supprimes :");
                                    for (StoreEntity store : storeListToDel) {
                                        System.out.println(store.getStoreName());
                                    }
                                }
                                break;
                            case 0:
                                inRestoSubMenu = false;
                                break;
                            default:
                                System.out.println("Mauvais choix, recommencez.");
                        }
                    }

                } else if (choice == 2) {
                    boolean inDishSubMenu = true;
                    while (inDishSubMenu) {
                        System.out.println("------------------------------------------------------");
                        System.out.println("Entrez une commande :");
                        System.out.println("1 = creer un plat ");
                        System.out.println("2 = voir la liste des plats ");
                        System.out.println("3 = supprimer un plat ");
                        System.out.println("4 = supprimer tous les plats ");
                        System.out.println("0 = Revenir au menu principal\n");
                        int choiceDish = Tx.readInt();
                        switch (choiceDish) {
                            case 1:
                                createDish();
                                break;
                            case 2:
                                List<DishEntity> dishListForResto = dishEntityFacade.getAllDishes();
                                if ((dishListForResto != null) && (dishListForResto.size() != 0)) {

                                    System.out.println("----Id----Nom----Prix----QT----------------------");
                                    for (DishEntity dish : dishListForResto) {
                                        System.out.println(dish.getDishId() + "    " + dish.getDishName() + "    " + dish.getPrice() + "    " + dish.getQuantity());
                                    }
                                } else {
                                    System.out.println("Pas de plats dans le menu!");
                                }
                                break;
                            case 3:
                                removeDish();
                                break;
                            case 4:
                                System.out.println(" -- Suprimer tous les plats");
                                List<DishEntity> dishList = dishEntityFacade.getAllDishes();
                                if ((dishList != null) && (dishList.size() != 0)) {
                                    cartSessionBean.removeAllItems();
                                    dishList = dishEntityFacade.removeAllDish();
                                    System.out.println("Vous avez supprime les suivants plats:");
                                    System.out.println("----Id----Nom-----------------------");
                                    for (DishEntity dish : dishList) {
                                        System.out.println(dish.getDishId() + "    " + dish.getDishName());
                                    }

                                } else {
                                    System.out.println("Pas de plats dans le menu!");
                                }
                                break;
                            case 0:
                                inDishSubMenu = false;
                                break;
                            default:
                                System.out.println("Mauvais choix, recommencez.");
                        }
                    }



                } else if (choice == 3) {

                    boolean inCustomerSubMenu = true;
                    while (inCustomerSubMenu) {
                        System.out.println("------------------------------------------------------");
                        System.out.println("Entrez une commande :");
                        System.out.println("1 = voir la liste des comptes clients ");
                        System.out.println("2 = supprimer un compte client ");
                        System.out.println("3 = supprimer tous les comptes clients ");
                        System.out.println("0 = Revenir au menu principal\n");
                        int choiceCustomer = Tx.readInt();
                        List<CustomerEntity> customerList;
                        switch (choiceCustomer) {
                            case 1:
                                customerList = customerEntityFacade.getAllCustomers();
                                if (customerList == null || customerList.size() == 0) {
                                    System.out.println("Il n'y a aucun client enregistre.");
                                } else {
                                    System.out.println("----Id----Nom----Prenom----AdresseEmail------------");
                                    for (CustomerEntity customer : customerList) {
                                        System.out.println(customer.getId() + "   " + customer.getFirstname() + " " + customer.getLastname() + " " + customer.getEmail());

                                    }
                                }
                                break;
                            case 2:
                                removeCustomer();
                                break;
                            case 3:
                                System.out.println(" -- Suprimer tous les clients");
                                customerList = customerEntityFacade.getAllCustomers();
                                if ((customerList != null) && (customerList.size() != 0)) {
                                    for (CustomerEntity customer : customerList) {
                                        cartSessionBean.removeAllItemsByCartId(customer.getId());
                                        cartSessionBean.removeAllCarts();
                                        //Main.cartSessionBean.removeAllItemsByCartId(customer.getCustomerCart().getId());
                                    }
                                    customerList = customerEntityFacade.removeAllCustomers();
                                    System.out.println("Les comptes clients suprimes sont:");
                                    System.out.println("----Id----Adresse Email----------------------");
                                    for (CustomerEntity customer : customerList) {
                                        System.out.println(customer.getId() + "    " + customer.getEmail());
                                    }

                                } else {
                                    System.out.println("Pas de comptes clients enregistres!");
                                }
                                break;
                            case 0:
                                inCustomerSubMenu = false;
                            default:
                                System.out.println("Mauvais choix, recommencez.");
                        }
                    }

                } else if (choice == 0) {
                    System.exit(0);

                } else {
                    System.out.println("Mauvais choix, recommencez.");
                }

            }
        } catch (Exception e) {
            System.err.println("Le client a rencontre une exception :( " + e);
            System.exit(2);
        }
    }

    private AddressEntity readAddress(int addressType) { //addressType = 1 for a customer, 2 for a restaurant

        AddressEntity address = new AddressEntity();

        address.setAddressType(addressType);

        System.out.println("Numero de la rue : ");
        String streetNum = Tx.readString();
        while (streetNum.matches("[0-9]+") == false) {
            System.out.println("Numero incorrect, recommencez : ");
            streetNum = Tx.readString();
        }
        address.setStreetNum(Integer.parseInt(streetNum));
        System.out.println("Nom de la rue : ");
        String streetName = Tx.readString();
        while (streetName.matches("[a-zA-Zéèçàù-[ ]]+") == false) {
            System.out.println("Nom de rue incorrect, recommencez : ");
            streetName = Tx.readString();
        }
        address.setStreetName(streetName);
        System.out.println("Code postal : ");
        String zipcode = Tx.readString();
        while (zipcode.matches("[0-9]+") == false) {
            System.out.println("Code postal incorrect, recommencez : ");
            zipcode = Tx.readString();
        }
        address.setZipcode(zipcode);
        System.out.println("Ville : ");
        String city = Tx.readString();
        while (city.matches("[a-zA-Zéèçàù-[ ]]+") == false) {
            System.out.println("Nom de ville incorrect, recommencez : ");
            city = Tx.readString();
        }
        address.setCity(city);

        // If we are reading the address of a customer, we have to ask if he/she leaves 
        // in a house or an apartment
        if (addressType == 1) {
            System.out.println("Le client habite-t'il dans un appartement ou une maison ?");

            boolean choice_made = false;

            while (!choice_made) {
                System.out.println("1 = appartement ");
                System.out.println("2 = maison ");
                int choice = Tx.readInt();
                if (choice == 1) {
                    System.out.println("Numero du batiment : ");
                    String buildingNum = Tx.readString();
                    while (buildingNum.matches("[0-9]+") == false) {
                        System.out.println("Numero incorrect, recommencez : ");
                        buildingNum = Tx.readString();
                    }
                    address.setBuildingNum(Integer.parseInt(buildingNum));
                    System.out.println("Numero de l'etage : ");
                    String floorNum = Tx.readString();
                    while (floorNum.matches("[0-9]+") == false) {
                        System.out.println("Numero incorrect, recommencez : ");
                        floorNum = Tx.readString();
                    }
                    address.setFloorNum(Integer.parseInt(floorNum));
                    System.out.println("Numero de l'appartement : ");
                    String apartmentNum = Tx.readString();
                    while (apartmentNum.matches("[0-9]+") == false) {
                        System.out.println("Numero incorrect, recommencez : ");
                        apartmentNum = Tx.readString();
                    }
                    address.setApartmentNum(Integer.parseInt(apartmentNum));
                    choice_made = true;
                } else if (choice == 2) {
                    choice_made = true;
                } else {
                    System.out.println("Mauvais choix, recommencez.");
                }
            }
        }
        return address;
    }

    private  AccountEntity readAccount(int accountType) {  //accountType = 1 for a customer, 2 for a restaurant

        AccountEntity account;

        System.out.println("IBAN du compte (FRxxx...) : ");
        String iban = Tx.readString();
        while (iban.matches("FR[0-9]+") == false) {
            System.out.println("IBAN incorrect, recommencez : ");
            iban = Tx.readString();
        }

        account = accountEntityFacade.getAccountByAccountIBAN(iban);
        while (account != null) {
            System.out.println("Le compte bancaire \"" + account.getAccountIBAN() + "\" existe deja.");
            System.out.println("IBAN du compte (FRxxx...) : ");
            iban = Tx.readString();
            while (iban.matches("FR[0-9]+") == false) {
                System.out.println("IBAN incorrect, recommencez : ");
                iban = Tx.readString();
            }
            account = accountEntityFacade.getAccountByAccountIBAN(iban);
        }
        account = new AccountEntity();
        account.setAccountType(accountType);
        account.setAccountIBAN(iban);
        return account;
    }

    private void createResto() {
        // We get the informations regarding a restaurant from the administrator
        // We verify the informations are correctly typed
        System.out.println("Entrez les informations concernant le restaurant :");
        System.out.println("Nom du restaurant : ");
        String restauName = Tx.readString();
        while (restauName.matches("[a-zA-Zéèçàù-[ ]]+") == false) {
            System.out.println("Nom incorrect, recommencez : ");
            restauName = Tx.readString();
        }
        StoreEntity store;
        store = storeEntityFacade.getStoreByName(restauName);
        while (store != null) {
            System.out.println("Le restaurant \"" + store.getStoreName() + "\" existe deja.");
            System.out.println("Nom du restaurant : ");
            restauName = Tx.readString();
            while (restauName.matches("[a-zA-Zéèçàù-[ ]]+") == false) {
                System.out.println("Nom incorrect, recommencez : ");
                restauName = Tx.readString();
            }
            store = storeEntityFacade.getStoreByName(restauName);
        }

        System.out.println("Nombre de places dans le restaurant : ");
        String seatsNumber = Tx.readString();
        while (seatsNumber.matches("[0-9]+") == false) {
            System.out.println("Nombre incorrect, recommencez : ");
            seatsNumber = Tx.readString();
        }
        System.out.println("Nombre de livreurs : ");
        String deliverymenNumber = Tx.readString();
        while (deliverymenNumber.matches("[0-9]+") == false) {
            System.out.println("Nombre incorrect, recommencez : ");
            deliverymenNumber = Tx.readString();
        }

        System.out.println("Entrez les informations concernant l'adresse du restaurant :");
        AddressEntity address = readAddress(2);

        System.out.println("Entrez les informations concernant le compte bancaire du restaurant :");
        AccountEntity account = readAccount(2);

        // Next we use the informations retrieved to create a new restaurant in the DB
        // and save its address too
        // to complete...

        StoreEntity newStore = storeEntityFacade.addStore(restauName,
                Integer.parseInt(seatsNumber),
                Integer.parseInt(deliverymenNumber),
                address,
                account);
        if (newStore == null) {
            System.out.println("Le restaurant n'a pas ete cree");
        } else {
            System.out.println("Restaurant cree.");
        }
    }

    private void removeResto() {
    	
        List<StoreEntity> storeList = storeEntityFacade.getAllStores();
        if ((storeList != null) && (storeList.size() != 0)) {
            System.out.println("La liste des restaurant:");
            System.out.println("---Id---Nom---");
            for (StoreEntity store : storeList) {
                System.out.println(" " + store.getId() + " " + store.getStoreName());
            }
            System.out.println("Entrez l'id du restaurant a supprimer : ");
            int restoId = Tx.readInt();

            StoreEntity storeToDel = storeEntityFacade.getStoreById(restoId);
            if (storeToDel == null) {
                System.out.println("Le restaurant \"" + restoId + "\" n'existe pas.");
            } else {
                System.out.println("Le restaurant \"" + restoId + "\" existe.");

                List<DishEntity> dishListForResto = dishEntityFacade.getAllDishesForResto(new Long(restoId));
                if ((dishListForResto != null)/* && (dishListForResto.size() != 0)*/) {
                    System.out.println("Le restaurant \"" + storeToDel.getStoreName() + "\" avec l'id " + storeToDel.getId() + "a les suivants plats associes, qui vont aussi etre suprimes:");
                    for (DishEntity dish : dishListForResto) {
                        System.out.println(dish.getDishId() + "    " + dish.getDishName() + "    " + dish.getPrice() + "    " + dish.getQuantity());
                    }
                        
                    List<CartEntity> cartList =  cartSessionBean.getAllCart();
                    
                    if(cartList != null && cartList.size() != 0){
                    	
                    	for (CartEntity cart : cartList){
                    		
                    		for (DishEntity dish : dishListForResto) {
                            	
                              	 cartSessionBean.removeProduct(cart.getId(),dish.getDishId());
                              	 
                              }
                    	}
                    	
                    }
                    
                    dishEntityFacade.removeAllDishesByRestoId(restoId);
                   
                }

                storeToDel = storeEntityFacade.removeStoreById(restoId);
                
                System.out.println("Le restaurant \"" + storeToDel.getStoreName() + " avec l'id " + storeToDel.getId() + " \" a ete supprime avec succes.");
            }
        } else {
            System.out.println("Aucun restaurant disponible");
        }
    }

    private void createDish() {
        List<StoreEntity> storeList = storeEntityFacade.getAllStores();

        if ((storeList == null) || (storeList.size() == 0)) {
            System.out.println("Pas de restaurants disponibles.");

        } else {
            //We ask first for the restaurant which will contain the dish to add
            System.out.println("Dans quel restaurant voulez-vous ajouter le plat?");
            System.out.println("Restaurants disponibles:");

            for (StoreEntity store : storeList) {

                System.out.println("------------------------------");
                System.out.println(store.getId());
                System.out.println(store.getStoreName());

            }

            System.out.println("Choisissez un restaurant par son identifiant:");
            int choixIdResto = -1;
            StoreEntity store = null;
            boolean foundStore = false;
            DishEntity dish;
            while (foundStore == false) {
                choixIdResto = Tx.readInt();
                store = storeEntityFacade.getStoreById(choixIdResto);
                if (store != null) {

                    foundStore = true;
                } else {
                    System.out.println("Identifiant de restaurant incorrect. Recommencez");
                }
            }


            // We get the informations regarding a meal from the administrator
            // We verify the informations are correctly typed
            System.out.println("Entrez les informations concernant le plat :");
            boolean dishExists = true;
            String mealName = "";
            while (dishExists) {
                System.out.println("Nom du plat : ");
                mealName = Tx.readString();
                while (mealName.matches("[a-zA-Zéèçàù-[ ]]+") == false) {
                    System.out.println("Nom incorrect, recommencez : ");
                    mealName = Tx.readString();
                }
                if (dishEntityFacade.getDishByNameAndStoreId(mealName,choixIdResto) == null) {
                    dishExists = false;

                } else {
                    //If we want some day to add more restaurants, we should not 
                    //add the restriction on the dish name. The dish should be able to exist in
                    //the DB more than one time but with different restaurants
                    //The problem could be solved if we ask and check the restarant id first
                    //and then the infos about the dish
                    System.out.println("Le plat existe deja dans le menu. Recommencez.");
                }
            }

            System.out.println("Type de plat : ");
            String mealType = Tx.readString();
            while (mealType.matches("[a-zA-Zéèçàù-[ ]]+") == false) {
                System.out.println("Type incorrect, recommencez : ");
                mealType = Tx.readString();
            }
            System.out.println("Quantite en stock : ");
            String quantity = Tx.readString();
            while (quantity.matches("[0-9]+") == false) {
                System.out.println("Nombre incorrect, recommencez : ");
                quantity = Tx.readString();
            }
            System.out.println("Prix : ");
            String price = Tx.readString();
            while (price.matches("[0-9]+") == false) {
                System.out.println("prix incorrect, recommencez : ");
                price = Tx.readString();
            }
            System.out.println("Nombre de calories : ");
            String calorieNum = Tx.readString();
            while (calorieNum.matches("[0-9]+") == false) {
                System.out.println("Nombre incorrect, recommencez : ");
                calorieNum = Tx.readString();
            }

            dish = dishEntityFacade.addDish(mealName, Double.parseDouble(price), Integer.parseInt(quantity), mealType, Integer.parseInt(calorieNum), store);
            if (dish == null) {
                System.out.println("Plat NULL");
            } else {
                System.out.println("Plat ajoute");
            }
        }
    }

    private void removeDish() {
        System.out.println(" -- Suprimer un plat par id");
        List<DishEntity> dishListForResto = dishEntityFacade.getAllDishes();
        if ((dishListForResto != null) && (dishListForResto.size() != 0)) {

            System.out.println("----Id----Nom----Prix----QT----------------------");
            for (DishEntity dish : dishListForResto) {
                System.out.println(dish.getDishId() + "    " + dish.getDishName() + "    " + dish.getPrice() + "    " + dish.getQuantity());
            }
            System.out.println("Entrez l'id du plat que vous voulez supprimer");
            int choiceIdDish = Tx.readInt();


            DishEntity temp = dishEntityFacade.getDishById(choiceIdDish);
            if (temp == null) {
                System.out.println("Aucun plat avec cet id.");
            } else {
                List<ItemEntity> allItems = cartSessionBean.getAllItems();
                if (allItems != null) {
                    for (ItemEntity item : allItems) {
                        if (item.getItemProduct().getDishId() == choiceIdDish) {
                            cartSessionBean.removeItem(item.getId());
                        }
                    }
                    temp = dishEntityFacade.removeDishById(choiceIdDish);
                    System.out.println("Le plat " + temp.getDishName() + " a ete suprime.");
                }
            }
        } else {
            System.out.println("Pas de plats dans le menu!");
        }

    }

    private void removeCustomer() {
        System.out.println(" -- Suprimer un compte client");
        List<CustomerEntity> customerList = customerEntityFacade.getAllCustomers();
        if ((customerList != null) && (customerList.size() != 0)) {

            System.out.println("----Id----Nom-------------------------");
            for (CustomerEntity customer : customerList) {
                System.out.println(customer.getId() + "    " + customer.getEmail());
            }
            System.out.println("Entrez l'id du client que vous voulez suprimer");
            int choiceId = Tx.readInt();

            
            
            cartSessionBean.removeAllItemsByCartId(new Long(choiceId));
            cartSessionBean.removeCartById(new Long(choiceId));

            List<CustomerEntity> temp = customerEntityFacade.removeCustomerById(new Long(choiceId));
            
            if ((temp != null) && (temp.size() != 0)) {
                System.out.println("Vous avez suprime le client suivant:");
                for (CustomerEntity customer : temp) {
                    System.out.println(customer.getId() + "    " + customer.getEmail());

                }
            } else {
                System.out.println("Aucun client avec cet id.");
            }
 
        } else {
            System.out.println("Pas de comptes client enregistres!");
        }
    }
	
	
	/**************************************************************/
	
	public static void main(String[] args) throws Exception {
   
			ExternAdmin adminTest = new ExternAdmin();
		
			adminTest.admin();

    }

	
}

